<template>
	<view class="">
		<view class="" v-for="(item,index) in arr" :key="index">
			<view class="wanshan" @click="xiangqing(item)">
				<BaseHouseList :arr="item.houses" :type="item.type"></BaseHouseList>
			</view>
			<view class="audit">
				<text class="person">提交人：{{item.agent_name}}</text>
				<view class="left">
					<view class="nopass" @click="nopass(item.id)">
						不通过
					</view>
					<view class="pass" @click="pass(item.id)">
						通过审核
					</view>
				</view>
			</view>
			<view class="hr"></view>
		</view>


		<u-popup v-model="show" mode="center">
			<view class="tangchubox">
				<textarea :value="remark" placeholder="请输入不通过原因" class="reason" @input="shuru" />
				<view class="submits" @click="submit">
					提交
				</view>
			</view>
		</u-popup>
	</view>
</template>

<script>
	import BaseHouseList from "../../components/BaseHouseList1/index.vue"
	import {getaudithouse} from "../../api/api/index.js"
	import {
		toaudit
	} from "../../api/api/index.js"
	export default {
		data() {
			return {
				arr: [],
				show: false,
				houseid:0,
				remark:"",
				page:0
			}
		},
		methods: {
			nopass(id){
				this.houseid=id
				this.show=true
				this.remark=""
			},
			submit(){
				let data={id:this.houseid,reason:this.remark,audit:2}
				let that=this
				getaudithouse(data).then(res=>{
					uni.showToast({
						title:res.message,
						icon:"none",
						duration:1000
					})
					that.arr=[]
					that.isOk=false
					that.page=0
					that.show=false
					that.remark=""
					that.requstlist()
				})
			},
			shuru(e){
				this.remark=e.detail.value
			},
			xiangqing(item){
				this.jumpLink({link:"/pages/listpage/index",query:{id:item.id,type:item.type}})
			},
			requstlist(){
				if(this.isOk){
					return uni.showToast({
						icon: 'none',
						title: '没有更多了'
					})
				}
				uni.showLoading({
					mask:true,
					title: '加载中'
				})
				this.page ++
				toaudit({
					page: this.page
				}).then(res => {
					uni.hideLoading()
					let arr = res.data.data.map(v => {
						v.house.img = v.house.image
						v.house.label = v.house.label
						v.house.total = v.house.unit_price
						v.houses = [v.house]
						return v
					})
					this.arr=this.arr.concat(arr)
					if(res.data.length < this.limit){
							this.isOk = true
						}
				})
			},
			pass(id){
				let data={id:id,audit:1}
				getaudithouse(data).then(res=>{
					uni.showToast({
						title:res.message,
						icon:"none",
						duration:1000
					})
					this.arr=[]
					this.isOk=false
					this.page=0
					this.requstlist()
				})
			}
		},
		components: {
			BaseHouseList
		},
		onShow() {
			this.page=0
			this.arr=[]
			this.isOk=false
			this.requstlist()
		},
		onReachBottom() {
			this.requstlist()
		}
	}
</script>

<style scoped lang="less">
	.wanshan{
		padding-left: 20rpx;
		box-sizing: border-box;
	}
	.audit {
		height: 108rpx;
		display: flex;
		justify-content: space-between;
		padding: 20rpx;
		box-sizing: border-box;
		border-top: 1rpx solid #ededed;

		.person {
			line-height: 68rpx;
		}

		.left {
			display: flex;
			justify-content: space-between;

			.nopass {
				width: 160rpx;
				height: 61rpx;
				background-color: #FFFFFF;
				border-radius: 31rpx;
				border: 3rpx solid #5f5f5f;
				line-height: 61rpx;
				text-align: center;
				color: #393939;
				font-size: 26rpx;
			}

			.pass {
				width: 160rpx;
				height: 61rpx;
				background-color: #ffffff;
				border-radius: 31rpx;
				border: solid 3rpx #df4744;
				line-height: 61rpx;
				text-align: center;
				color: #d72f2c;
				font-size: 26rpx;
				margin-left: 29rpx;
			}
		}
	}

	.hr {
		height: 15rpx;
		background-color: #ededed;
	}
	.tangchubox{
		width: 658rpx;
		.reason{
			font-size: 30rpx;
			padding: 20rpx;
			box-sizing: border-box;
		}
		.submits{
			width: 658rpx;
			height: 100rpx;
			text-align: center;
			line-height: 100rpx;
			background-color: #ef0000;
			color: #FFFFFF;
		}
	}
	
</style>
